package main.java.com.lee.thread;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2021/12/4
 */
public class WarterCal {


	public static void main(String[] args) {
		//南

		BigDecimal southPrevious = BigDecimal.valueOf(484.3);
		BigDecimal southCurrent = BigDecimal.valueOf(504.7);

		//北
		BigDecimal northPrevious = BigDecimal.valueOf(650.1);
		BigDecimal northCurrent = BigDecimal.valueOf(715.0);

		BigDecimal money = BigDecimal.valueOf(74.10);
		BigDecimal total = northCurrent.subtract(northPrevious).add(southCurrent.subtract(southPrevious));

//		BigDecimal totalEle = north.add(sourth);
//		System.out.println("单价: " + amount.divide(totalEle, RoundingMode.HALF_UP));
//		System.out.println("11月抄表: 北, 电量: "+north+", 电费: " + amount.multiply(north).setScale(10, RoundingMode.HALF_UP).divide(totalEle, RoundingMode.HALF_UP));
//		System.out.println("11月抄表: 南, 电量: " + sourth + ",电费: " + amount.multiply(sourth).setScale(10, RoundingMode.HALF_UP).divide(totalEle, RoundingMode.HALF_UP));
		int month=11;
		cal(month, southPrevious, southCurrent, money, total, "朝向南");
		cal(month, northPrevious, northCurrent, money, total, "朝向北");

	}

	// 朝南租客旧租客, 2吨水费未付款, 需房东结清. 有聊天记录
	private static void cal(int month, BigDecimal one, BigDecimal three, BigDecimal amount, BigDecimal total, String dir) {
		System.out.println(dir + "," + month + "月初抄表: " + one + " ," + month + "月底抄表: " + three + ", 本期用量: " + three.subtract(one) +
			", 本期费用: " + amount.multiply(three.subtract(one)).setScale(10, RoundingMode.HALF_UP).divide(total, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
	}

	//上一期抄表: 355.6 ,当期抄表: 366.2, 电量: 10.6, 电费: 27.0848275862
}
